<%@page import="java.awt.Window"%>
<%@ page import="ilikethat.*"%>
<%@ page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%

	// Parameter werden ausgelesen
	String facebookID = request.getParameter("FbId");
	System.out.print(Select.getPlayerInfo("players", facebookID));

	String facebookPicture = "https://graph.facebook.com/" + facebookID
			+ "/picture?width=150&height=150";
	//Punkte aus der datenbank holen und das entsprechende Level berechnen
	String pointsString = Select.getPoints("players", facebookID);
	int points = Integer.parseInt(pointsString);
	int level = 0;
	if(points <= 100) {
		level += 1;
	} else if(100 < points && points <= 300) {
		level += 2;
	} else if(300 < points && points <= 600) {
		level += 3;
	} else if(600 < points && points <= 1000) {
		level += 4;
	} else if(1000 < points && points <= 1500) {
		level += 5;
	} else if (1500 < points) {
		points -= 1500;
		while(points > 500) {
			points -= 500;
			level ++;
		}
	}
	String levelString = "" + level + "";
	Insert.insertNewLevel(facebookID, levelString);
	
%>
<div id="profile">
	<img src="<%=facebookPicture%>" style="box-shadow: 1px 1px 1px #888888;">
	<table id="stats" align="right">
		<tr>
			<th>Name:</th>
			<td id="name">
				<script>
					var name = localStorage.name;
					document.getElementById('name').innerHTML = name;
				</script>
			</td>
<%-- 			<td><%=Select.getPlayerName("players", facebookID)%></td> --%>
		</tr>
		<tr>
			<th>Punkte:</th>
			<td><%=Select.getPoints("players", facebookID)%></td>
		</tr>
		<tr>
			<th>Level:</th>
			<td><%=Select.getLevel("players", facebookID)%></td>
		</tr>
		<tr>
			<th>Auszeichnungen:</th>
			<td><%=Select.getAwards("players", facebookID)%></td>
		</tr>
	</table>
</div>
